<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ShowClass</title>
    <link rel="stylesheet" href="/Trees/LayUiBac/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-container">
    <div class="layui-row">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">班级名称</label>
                <div class="layui-input-block">
                    <input type="text" name="className" required lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">管理人员</label>
                <div class="layui-input-block">
                    <input type="text" name="people" required lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">具体人数</label>
                <div class="layui-input-block">
                    <input type="text" name="num" required lay-verify="required"
                           autocomplete="off" class="layui-input" >
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">电话号码</label>
                <div class="layui-input-block">
                    <input type="text" name="tel" required lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">地区名称</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="text" name="area" required lay-verify="required"-->
<!--                           autocomplete="off" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <label class="layui-form-label">地区名称</label>
                <div class="layui-input-block">
                    <select name="area" id="area" lay-verify="required">
                        <option value=""></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
</div>


<script src="/Trees/LayUiBac/layui/layui.js"></script>

<script>
    //Demo
    layui.use(['form','jquery','layer'],function () {
        let form = layui.form;
        let layer = layui.layer;
        let $ = layui.$;
        form.render();
        let x ='';

        $.ajax({
            type:"post"
            ,url:"/Trees/classManage?method=showNoClass"
            ,dataType:'json'
            ,success:function (data) {
                console.log(data)
                for(let i of data){
                    x+="<option value="+i.name+">"+i.name+"</option>"
                }
                $('#area').html(x);
                form.render('select');
            }
        })

        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
</body>
</html>